<?php

class IncidentAdmin extends Incident
{

    function handlePOST( Event $e )
    {
        if ( $e->tag == 'reply' ) {
            if ( empty( $_POST[ 'text' ] ) ) $this->errors[ ] = 'text';

            $e->cancelBubble();
        }
        else parent::handlePOST( $e );
    }

    function doPOST( Event $e )
    {
        if ( $e->tag == 'reply' ) $this->reply();
        else parent::doPOST( $e );
    }

    function reply()
    {
        //primero tengo que comprobar si hahy algun archivo parar incorporalo a la incidencia
        $numfiles = 0;

        if ( isset( $_FILES[ 'attacheds' ] ) ) {
            if ( is_array( $_FILES[ 'attacheds' ] ) ) {
                
            }
            //tengo que obtener el tipo el tamaño el nombre original
        }

        $sql = 'INSERT INTO messages (projec,destination,parent_message,owner,when,replys,replicable,duration,files) VALUES';
        $sql.='(' . $this->project . ',' . $this->destination . ',' . $this->id . ',' . Mesage::$user_id . ',NOW(),0,\'S\',' . MyLink::quote( $_POST[ 'horas' ] . ':' . $_POST[ 'minutos' ] ) . ',' . $numfiles . ')';
        MyLink::$default->execute( $string );
    }

}

?>
